import java.util.Random;

public class Die
{
    // Empty zero-arg constructor for Die class
    private Die()
    {       
    	
    }
    
    
    /**
     * Constructor for the Die class
     */
    public Die(Random rand)
    {        
        this.roll(rand);
    }
    
    
    /**
     * Rolls the die.
     * 
     * @return Die
     */
    public Die roll(Random rand)
    {
        _number = getDiceNumber(rand.nextInt(DICE_FACES));
        _color = _number.getColour();
        
        return this;
    }
    
    
    /**
     * Returns the number of the Die rolled
     * 
     * @return DiceNumber
     */
    public DiceNumber getNumber()
    {
        return _number;
    }
    
    
    /**
     * Returns the color of the Die rolled
     * 
     * @return DiceColor
     */
    public DiceColor getColor()
    {
        return _color;
    }
    
    
    /**
     * Returns a DiceNumber from the random integer rolled.
     * 
     * @param num
     * @return DiceNumber
     */
    private static DiceNumber getDiceNumber(int num)
    {
        DiceNumber diceNum = null;
        
        // Creates the proper DiceNumber enum from the random number
        // generated
        switch (num)
        {
            case 0:     diceNum = DiceNumber.ace; 
                        break;
            case 1:     diceNum = DiceNumber.deuce; 
                        break;
            case 2:     diceNum = DiceNumber.trey;
                        break;
            case 3:     diceNum = DiceNumber.four;
                        break;
            case 4:     diceNum = DiceNumber.five;
                        break;
            case 5:     diceNum = DiceNumber.six;
                        break; 
        }    
        
        return diceNum;
    }
    
    // Instance variables
    private DiceColor _color;
    private DiceNumber _number;
    private final int DICE_FACES = 6;
}

